﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace UpdaterForm.Utils
{
    public class FileUtil
    {
        private static List<String> ignoreFiles = new List<string>{Settings.Instance.MessageFileName};

       public static FileInfo[] ListFiles(DirectoryInfo directory)
       {
           var files = directory.GetFiles("*", SearchOption.AllDirectories);

           return files.Where(
               file => !ignoreFiles.Contains(file.Name)
               ).ToArray();
       }

       public static void MoveFile(String to, FileInfo file)
       {
           if (ignoreFiles.Contains(file.Name))
               return;

           if (!Directory.Exists(to))
               Directory.CreateDirectory(to);
           file.CopyTo(Path.Combine(to, file.Name), true);
       }
        public static List<string> ListAppFiles(string installPath)
        {
            var files = new List<string>();
            files.AddRange(Directory.GetFiles(installPath, "*.dll", SearchOption.AllDirectories));
            files.AddRange(Directory.GetFiles(installPath, "*.exe", SearchOption.AllDirectories));
            return files;
        }
    }
}
